package com.ln.adoms.service;

import javax.annotation.Resource;

import com.ln.adoms.entity.Brand;
import com.ln.core.orm.hibernate.BaseDao;
import com.ln.core.orm.hibernate.BaseService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional
public class BrandService extends BaseService<Brand> {
    @Override
    @Resource(name = "brandDao")
    public void setBaseDao(BaseDao<Brand> baseDao) {
        this.baseDao = baseDao;
    }


    public List<Brand> findBrandByDepartmentID(Integer departmentID) {

        String sql = "select brand_id from brand_department where department_id = " + departmentID;
        List<Integer> ids = this.find(sql);

        if (ids != null && !ids.isEmpty()) {
            List<Brand> brands = this.findListByIds(ids);
            return brands;
        }

        return null;
    }
}
